home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / jazlib.arc / RSPLIST.C < prev    next >
Text File  |  1988-12-18  |  893b  |  48 lines

  1. #include <stdio.h>
  2. #include <jaz.h>
  3. THEAD *rsplist(fname)
  4. char *fname;
  5. {
  6.   TNAME *p;
  7.  
  8.   THEAD *whead,*readlist();
  9.  
  10.   whead = (THEAD *) malloc(sizeof(THEAD));
  11.  
  12.   whead->listlen = 0;
  13.   whead->first = whead->last = 0;
  14.  
  15.   whead = readlist(fname,whead);
  16.  
  17. }
  18.  
  19. THEAD *readlist(fname,fhead)
  20. char *fname;
  21. THEAD *fhead;
  22. {
  23.   FILE *fd;
  24.   int num;
  25.   char wbuf[256],*ch;
  26.   TNAME *wnew;
  27.  
  28.   if ( !(fd = fopen(fname ,"r"))) return(0);
  29.  
  30.   while ( (ch = fgets(wbuf,num,fd)) ) {
  31.     wbuf[strlen(wbuf)-1] = 0; /* get rid of newline char */
  32.     wnew = (TNAME *) malloc(sizeof(TNAME));
  33.     wnew->filename = (char *) malloc(strlen(wbuf)+1);
  34.     if (fhead->first)
  35.       fhead->last->next = wnew;
  36.     else
  37.       fhead->first = wnew;
  38.     wnew->next = 0;
  39.     fhead->last = wnew;
  40.     fhead->listlen ++;
  41.     strcpy(wnew->filename,wbuf);
  42.   }
  43.   fclose(fd);
  44.  
  45.   return(fhead);
  46. }
  47.  
  48.